import RPi.GPIO as GPIO
import Adafruit_DHT

sensor = Adafruit_DHT.DHT11
pin = 4
humidity, temperature = Adafruit_DHT.read_retry(sensor, pin)

if humidity is not None and temperature is not None:
    print('Temp={0:0.1f}*C  Humidity={1:0.1f}%'.format(temperature, humidity))
else:
    print('Failed to get reading. Try again!')


# initialize GPIO GPIO.setwarnings(False) GPIO.setmode(GPIO.BCM) GPIO.cleanup()
# read data using pin 14 instance = dht11.DHT11(pin = 4) result = instance.read()

#if result.is_valid():
#    print("Temperature: %-3.1f C" % result.temperature)
#    print("Humidity: %-3.1f %%" % result.humidity)
#else:
#    print("Error: %d" % result.error_code)

